package com.helei.springcloud.entity;

import java.util.HashMap;

/**
 * @description: 描述
 * @create: 2019-02-25 14:22
 */
public class Resp extends HashMap<String, Object> implements Cloneable{

    private Resp() { }

    public static Resp getNew(){
        return new Resp();
    }
    public Resp success() {
        this.put("code", "1");
        this.put("message", "请求成功");
        return this;
    }
    public Resp success(String message) {
        this.put("code", "1");
        this.put("message", message);
        return this;
    }
    public Resp structure(String res, String message) {
        this.put("code", res);
        this.put("message", message);
        return this;
    }
    public Resp success(String key, Object value) {
        this.put(key, value);
        return this;
    }

    public Resp success(Object value) {
        this.put("code", "1");
        this.put("message", "成功");
        this.put("data", value);
        return this;
    }

    public Resp fail() {
        this.put("code", "-1");
        this.put("message", "系统错误");
        return this;
    }

    public Resp fail(String message) {
        this.put("code", "-1");
        this.put("message", message);
        return this;
    }

    public Resp fail(String key, Object value) {
        this.put("code", "-1");
        this.put(key, value);
        return this;
    }

    @Override
    public Object clone() {
        return super.clone();

    }
}
